﻿@model ShipmentDetailsModel

@if (string.IsNullOrEmpty(Model.RateName))
{
    @if (Model.AvailableRates.Any(rate => !string.IsNullOrEmpty(rate.Value)))
    {
        <button type="submit" asp-route="@EasyPostDefaults.BuyLabelRouteName" class="btn bg-purple">
            <i class="fa fa-barcode"></i>
            @T("Plugins.Shipping.EasyPost.Shipment.BuyLabel")
        </button>
    }
    <button type="submit" asp-route="@EasyPostDefaults.UpdateShipmentRouteName" class="btn btn-primary">
        <i class="fa fa-save"></i>
        @T("Plugins.Shipping.EasyPost.Shipment.UpdateShipment")
    </button>
}
else
{
    @await Html.PartialAsync("~/Plugins/Shipping.EasyPost/Views/Pickup/_PickupButtons.cshtml", Model.PickupModel)
    <div class="btn-group">
        <button type="button" class="btn btn-success">
            <i class="fa fa-download"></i>
            @T("Plugins.Shipping.EasyPost.Shipment.DownloadLabel")
        </button>
        <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
            <span class="caret"></span>
            <span class="sr-only">&nbsp;</span>
        </button>
        <ul class="dropdown-menu" role="menu">
            <li>
                <button type="submit" asp-route="@EasyPostDefaults.DownloadLabelRouteName" asp-route-labelFormat="png">
                    <i class="far fa-file-image"></i>
                    @T("Plugins.Shipping.EasyPost.Shipment.DownloadLabel.Png")
                </button>
            </li>
            <li>
                <button type="submit" asp-route="@EasyPostDefaults.DownloadLabelRouteName" asp-route-labelFormat="pdf">
                    <i class="far fa-file-pdf"></i>
                    @T("Plugins.Shipping.EasyPost.Shipment.DownloadLabel.Pdf")
                </button>
            </li>
            <li>
                <button type="submit" asp-route="@EasyPostDefaults.DownloadLabelRouteName" asp-route-labelFormat="zpl">
                    <i class="far fa-file"></i>
                    @T("Plugins.Shipping.EasyPost.Shipment.DownloadLabel.Zpl")
                </button>
            </li>
        </ul>
    </div>
    if (Model.InvoiceExists)
    {
        <button type="submit" asp-route="@EasyPostDefaults.DownloadInvoiceRouteName" class="btn btn-success">
            <i class="far fa-file-pdf"></i>
            @T("Plugins.Shipping.EasyPost.Shipment.DownloadInvoice")
        </button>
    }
}